<template>
	<view class="apply-item">
		<view class="info">
			<view class="name">
				<view>姓名</view>
				<view>{{ real_name }}</view>
			</view>
			<view class="apply-cause">
				<view>申请原因</view>
				<view>{{ apply_cause }}</view>
			</view>
			<view class="apply-time">
				<view>申请时间</view>
				<view>{{ apply_date | dateFormat }}</view>
			</view>
			<view class="apply_role">
				<view>申请权限</view>
				<view>{{ role }}</view>
			</view>
		</view>
		<view class="apply_type">
			<view>申请状态</view>
			<view>{{ status }}</view>
		</view>
		<view class="button">
			<view class="pass" @click="pass">通过</view>
			<view class="refuse" @click="refuse">驳回</view>
		</view>
	</view>
</template>

<script>
	export default {
		// props:['real_name','apply_cause','apply_date','apply_role','apply_type','id'],
		props:{
			real_name: {
				type:String,
				default:'asd'
			},
			apply_cause: {
				type:String,
				default:'asd'
			},
			apply_date: {
				
			},
			apply_role: {
				type:Number,
				default:1
			},
			apply_type: {
				type:Number,
				default : 1
			},
			no: {
				
			},
		},
		computed:{
			role(){
				if(this.apply_role === 1) return '管理员'
				if(this.apply_role === 2) return '教师'
				if(this.apply_role === 3) return '学生'
			},
			status(){
				if(this.apply_type === 1) return '待审核'
				if(this.apply_type === 2) return '通过'
				if(this.apply_type === 3) return '驳回'
			}
		},
		filters:{
			dateFormat(time){
				var date = new Date(time)
				var y = date.getFullYear()
				var m = padZero(date.getMonth() + 1)
				var d = padZero(date.getDate())
				var h = padZero(date.getHours())
				var mm = padZero(date.getMinutes())
				var s = padZero(date.getSeconds())
				return y + '年' + m + '月' + d + '日  ' + h + ':' + m + ':' + s
			}
		},
		methods:{
			refuse(){
				var obj = {}
				obj.id = this.no
				obj.type = 2
				obj.refuse_cause = '不让过'
				this.$emit('refuse',obj)
			},
			pass(){
				var obj = {}
				obj.id = this.no
				obj.type = 1
				obj.refuse_cause = '给你过'
				this.$emit('refuse',obj)
			}
		}
	}
	function padZero(n) {
		return n > 9 ? n : '0' + n
	}
</script>

<style lang="less">
	.apply-item {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		width: 98%;
		height: 500rpx;
		margin: 0 auto;
		margin-top: 50rpx;
		text-align: center;
		border-radius: 15rpx;
		background-color: #FFFFFF;

		.info {
			display: flex;
			justify-content: space-around;
		}

		.button {
			display: flex;

			.pass,
			.refuse {
				flex: 50%;
				background-color: skyblue;
				height: 60rpx;
				line-height: 60rpx;
				color: #FFFFFF;
			}
			.refuse {
				background-color: #b82f28;
			}
		}
	}
</style>
